<link rel="stylesheet" href="/css/topicApps.css">
<div class="main layui-clear">
	<div class="wrap layui-clear">
		<div class="layui-left">
		    <div class="layui-bar mobile-display-none">
		    	<div class="layui-breadcrumbs">
			    	<a class="home" href="/"></a>
					<i class="layui-icon">&#xe602;</i>
					<a href="/topic/topicIndex">谈天说地</a>
		    	</div>
		    </div>
		    <#if blockList??>
		    <div class="right-edge-mobile pc-display-none">
		        <div class="recommend-section">
		        	<span class="text">推荐板块</span>
		        </div>
		        <#assign blockNum=0 >
		        <#list blockList as block>
					<#if block.type=="板块">
					<#assign blockNum="${blockNum?number + 1}" >
					</#if>
				</#list>
		        <div class="plate-list" <#if (blockNum?number<=2)>style="overflow:hidden"</#if>>
		        	<div class="nowrap" style="width: ${blockNum?number*5}rem">
						<#list blockList as block>
							<#if block.type=="板块">
								<a onclick="searchHref('','${block.id!''}','${RequestParameters['q']!''}','${subtype!''}')"  class="layui-clear">
									<div class="card-list <#if block.id==cateparent>this </#if>">
					        			<span class="class"><img alt="" src="/res/blockmanagement/${block.fileurl!''}.html"></span>
					        			<span  title="${block.blockname!''}"  class="class-title">${block.blockname!''}</span>
					        		</div>
								</a>
							</#if>
						</#list>
		        	</div>
		        </div>
		    </div>
		    </#if>
		    <div class="content" style="margin-right:0px;">
		    	<#if cateparent != ""> 
		    	<div class="content-cateparent layui-clear">
		    	 <#if blockList??>
					<#list blockList as block>
						<#if block.id==cateparent>
							<img alt="" src="/res/blockmanagement/${block.graphurl!''}.html">
				    		<div class="content-cateparent-information">
				    			<h1>${block.blockname!''}</h1>
				    			<div class="content-cateparent-text mobile-display-none" title="${block.briefintroduction!''}">
				    				<#if (block.briefintroduction?length>185)>
							          <span class="briefintroduction-substring">${block.briefintroduction[0..184]?default("")}...<a class="show-close"  onclick="showBriefintroduction(this)">更多</a></span>
							          <span class="briefintroduction-allsubstring layui-hide"> ${block.briefintroduction!''}<a class="show-close" onclick="showBriefintroduction(this)">收起</a></span>
							        <#else>
							          ${block.briefintroduction!''}
							        </#if> 
				    			</div>
				    			<div class="content-cateparent-text pc-display-none" title="${block.briefintroduction!''}">
				    				<#if (block.briefintroduction?length>90)>
							          <span class="briefintroduction-substring">${block.briefintroduction[0..90]?default("")}...<a class="show-close"  onclick="showBriefintroduction(this)">更多</a></span>
							          <span class="briefintroduction-allsubstring layui-hide"> ${block.briefintroduction!''}<a class="show-close" onclick="showBriefintroduction(this)">收起</a></span>
							        <#else>
							          ${block.briefintroduction!''}
							        </#if> 
				    			</div>
				    		</div>
						</#if>
					</#list>
					</#if>
		    	</div>
		    	</#if>
		    	<div class="content-main">
		    		<span class="molibe-title pc-display-none">帖子</span>
			    	<div class="fly-tab">
			    		 <!-- pc分类 -->
			    		<#if cateparent!="">
				    		<h4 class="mobile-display-none">分类</h4>
							<span id="showList"  class="mobile-display-none">
					        <a onclick="searchHref('','${cateparent!''}','${RequestParameters['q']!''}','${subtype!''}')" <#if cate?? && cate == "">class="tab-this"</#if>>全部</a>
					        <#if blockList??> 
							<#list blockList as list>
							<#if list.type=="分类">
								<#if cateparent == "" || cateparent ==list.parentid >
								<#if listX??><#assign listX = listX + 1><#else> <#assign listX = 1></#if>
									<#if listX <= 7>
										<#if listX!=1>
										<span class="cut-off">|</span>
										</#if>
										 <a title="${list.blockname!''}" onclick="searchHref('${list.id!''}','${list.parentid!''}','${RequestParameters['q']!''}','${subtype!''}')" <#if cate?? && cate == list.id>class="tab-this"</#if>>
										 <#if (list.blockname?length>4)>
									        ${list.blockname[0..3]?default("")}...
									        <#else>
									          ${list.blockname!''}
									      </#if> 
									      </a> 
											<#if listX%7==0>
												<br><span style="margin-left: 34px;"></span>
											</#if>
									<#else>
										<#if listX%7!=1>
										<span class="cut-off" type="hide">|</span>
										</#if>
									    <a type="hide" title="${list.blockname!''}" onclick="searchHref('${list.id!''}','${list.parentid!''}','${RequestParameters['q']!''}','${subtype!''}')" <#if cate?? && cate == list.id>class="tab-this"</#if>>
										 <#if (list.blockname?length>4)>
									        ${list.blockname[0..3]?default("")}...
									        <#else>
									          ${list.blockname!''}
									      </#if> 
									   </a> 
									   <#if listX%7==0>
											<br><span style="margin-left: 34px;"></span>
										</#if>
									</#if>
								</#if>  
							</#if>
							</#list>
							</#if>
							</span>
							<#if listX?? && (listX>7)>
							<span class="list-more mobile-display-none" onclick="showTimeLi()">更多<i class="layui-icon">&#xe61a;</i></span>
							</#if>
							<hr class="mobile-display-none">
						</#if>
						<h4>筛选</h4>
						<span class="other-fly">
				          <a onclick="searchHref('','${cateparent!''}','${RequestParameters['q']!''}','topicIndex')"  <#if subtype?? && subtype == "topicIndex">class="tab-this"</#if>>全部</a>
				          <a onclick="searchHref('${cate!''}','${cateparent!''}','${RequestParameters['q']!''}','finish')" <#if subtype?? && subtype == "finish">class="tab-this"</#if>>结贴</a><span class="cut-off mobile-display-none">|</span>
				          <a onclick="searchHref('${cate!''}','${cateparent!''}','${RequestParameters['q']!''}','accept')" <#if subtype?? && subtype == "accept">class="tab-this"</#if>>采纳</a><span class="cut-off mobile-display-none">|</span>
				          <a onclick="searchHref('${cate!''}','${cateparent!''}','${RequestParameters['q']!''}','essence')" <#if subtype?? && subtype == "essence">class="tab-this"</#if>>精帖</a>
				          <#if user??>
				          	<span class="cut-off mobile-display-none" >|</span><a href="/topic/my.html" <#if subtype?? && subtype == "my">class="tab-this"</#if>>我的帖</a>
				          </#if>
				        </span>
				        <span class="search-time" onmouseleave="$('.search-time-li').css('display','none')" >
							<h4 class="mobile-display-none">筛选</h4>
							<span onclick="$('.search-time-li').css('display','block')" >按时间</span>
							<div >
								<div class="search-time-li">
									<ul>
										<li <#if time == ''> class="this"</#if> onclick="searchHref('${cate!''}','${cateparent!''}','${RequestParameters['q']!''}','${subtype!''}','','')">全部</li>
										<li <#if time == '1'> class="this"</#if> onclick="searchHref('${cate!''}','${cateparent!''}','${RequestParameters['q']!''}','${subtype!''}','','1')">一天</li>
										<li <#if time == '2'> class="this"</#if> onclick="searchHref('${cate!''}','${cateparent!''}','${RequestParameters['q']!''}','${subtype!''}','','2')">一周</li>
										<li <#if time == '3'> class="this"</#if> onclick="searchHref('${cate!''}','${cateparent!''}','${RequestParameters['q']!''}','${subtype!''}','','3')">一个月</li>
									</ul>
								</div>
							</div>
						</span>
				      </div>
				      
				      <!-- 移动端分类 -->
				      <#if cateparent!="">
				      <div class="pc-display-none mobile-block-type">
				      	<h4>分类</h4>
						<span>
					        <a onclick="searchHref('','${cateparent!''}','${RequestParameters['q']!''}','${subtype!''}')" <#if cate?? && cate == "">class="tab-this"</#if>>全部</a>
					        <#if blockList??> 
							<#list blockList as list>
							<#if list.type=="分类">
								<#if listX??><#assign listX = listX + 1><#else> <#assign listX = 1></#if>
								<#if cateparent == "" || cateparent ==list.parentid >
									<#if listX!=1>
										<span class="cut-off">|</span>
										</#if>
									 <a title="${list.blockname!''}" onclick="searchHref('${list.id!''}','${list.parentid!''}','${RequestParameters['q']!''}','${subtype!''}')" <#if cate?? && cate == list.id>class="tab-this"</#if>>
								          ${list.blockname!''}
								      </a> 
								</#if>  
							</#if>
							</#list>
							</#if>
						</span>
				      </div>
				      </#if>
				      <ul class="fly-list">
				      	<#if defaultTopicList??>
				      	<#list defaultTopicList.content as topic>
				        <li class="fly-list-li">
				        <#if topic.username == user.username>
				        	<!-- pc端帖子头像 -->
				          <a href="/user/profile.html" class="fly-list-avatar mobile-display-none">
				            <img src="/${user.fileurl!''}"onerror="this.src='/images/user/default.jpg';this.onerror=null">
				          </a>
				          <!-- 移动端帖子头像 -->
				          <a href="/user/index.html" class="fly-list-avatar pc-display-none">
				            <img src="/${user.fileurl!''}"onerror="this.src='/images/user/default.jpg';this.onerror=null">
				          	<span class="mobile-username">${topic.username!''}</span>
				          </a>
				           <#if topic.top =="true">
				            	<span class="topic-tip top pc-display-none"></span>
				            </#if>
				            <#if topic.essence == "true">
				            	<span class="topic-tip essence pc-display-none"></span>
				            </#if>
				            <#if topic.enclosure == "true">
				            	<span class="topic-tip file pc-display-none"></span>
				            </#if>
				          <#else>
				          	<!-- pc端帖子头像 -->
				          	<a href="/user/otherUser/${topic.creater}.html" target="_blank" class="fly-list-avatar mobile-display-none">
					            <img src="/${topic.user.fileurl!''}" onerror="this.src='/images/user/default.jpg';this.onerror=null">
					          </a>
					          <!-- 移动端帖子头像 -->
					          <a href="/user/otherUser/${topic.creater}.html" target="_blank" class="fly-list-avatar pc-display-none">
					            <img src="/${topic.user.fileurl!''}" onerror="this.src='/images/user/default.jpg';this.onerror=null">
					            <span class="mobile-username">${topic.username!''}</span>
					          </a>
					          <#if topic.top =="true">
					            	<span class="topic-tip top pc-display-none"></span>
					            </#if>
					            <#if topic.essence == "true">
					            	<span class="topic-tip essence pc-display-none"></span>
					            </#if>
					            <#if topic.enclosure == "true">
					            	<span class="topic-tip file pc-display-none"></span>
					            </#if>
				          </#if>
				          <h2 class="fly-tip">
				            <label class="tip-type">
				            	<#if (topic.block.blockname?length > 5)>
				            		<label title="${topic.block.blockname!''}">${topic.block.blockname[0..4]?default("")}</label>
				            	<#else>
				            	 	${topic.block.blockname!''}
				            	</#if>
				            </label>
				            <a title="${topic.title!''}" href="/topic/detail/${topic.id!''}.html">${topic.title!''}</a>
				           	<!-- pc帖子标签 -->
				            <i class="mobile-display-none">
					            <#if topic.top =="true">
					            	<span class="topic-tip top"></span>
					            </#if>
					            <#if topic.essence == "true">
					            	<span class="topic-tip essence"></span>
					            </#if>
					            <#if topic.enclosure == "true">
					            	<span class="topic-tip file"></span>
				            	</#if>
				            </i>
				          </h2>
				          <p>
			          	  <#if topic.username == user.username>
					        <span class="mobile-display-none"><a href="/user/profile.html">${topic.username!''}</a>
					        </span>
					        <span class="cut-off mobile-display-none">|</span>
				          <#else>
				          	<span class="mobile-display-none"><a href="/user/otherUser/${topic.creater}.html" target="_blank">${topic.username!''}</a>
					          	<a class="show-user-msg">
						          	<span title="${topic.username!''}" class="title"  onclick="window.open('/user/otherUser/${topic.creater}.html')">${topic.username!''}</span>
						          	<#if topic.user.usertype=="0">
						          		<span class="grade">( 管理员 )</span><br>
						          	<#else>
						          		<span class="grade"> lv${topic.user.grade.grade!''}.${topic.user.grade.groups!''} </span><br>
						          	</#if>
						          	
						          	<span class="memo">${topic.user.memo!''}</span><br>
						          	<#if user??>
							          	<#if topic.user.fansIs =="No">
							          		<span id="followsB${topic.user.id!''}" class="follow" onclick="fans('${topic.user.id!''}')"><span class="topic-follow-tip"></span><b>关注</b></span>
										<#else>
											<span id="followsB${topic.user.id!''}" class="follow" onclick="unfans('${topic.user.id!''}')"><span class="topic-follow-tip"></span><b>已关注</b></span>
										</#if>
									<#else>
							          	<span id="followsB${topic.user.id!''}" class="follow" onclick="window.location.href = '/login'"><span class="topic-follow-tip"></span><b>关注</b></span>
						          	</#if>
						          	<span class="messageBoade" onclick="window.open('/messageboard/otherIndex/${topic.user.id!''}.html')"><span class="topic-mess-tip"></span>留言</span>
					        	</a>
				          	</span>
				          	<span class="cut-off mobile-display-none">|</span>
				          </#if>
				            <span>${topic.updatetime?string('yyyy-MM-dd HH:mm')}</span><span class="cut-off mobile-display-none">|</span>
				            <span class="mobile-float-right">回复 ${topic.answers!0}</span><span class="cut-off mobile-display-none">|</span>
				            <span class="mobile-float-right">浏览 ${topic.views!0}</span>
				          </p>
				          <#if topic.finish==true>
				          	<span class="stick"></span>
				          </#if>
				        </li>
				        </#list>
				        </#if>
				      </ul>
		    	</div>
		    	<!-- pc端分页 -->
		    	<div style="text-align: center" class="front-desk mobile-display-none">
		          <div class="laypage-main" id="pages"></div>
		        </div>
		        <!-- 移动端分页 -->
		        <div style="text-align: center" class="front-desk pc-display-none">
		          <div class="laypage-main" id="pagesMobile"></div>
		        </div>
		    </div>
	    </div>
	    <div class="layui-right">
	    	<div class="right-edge show mobile-display-none">
		        <div class="plate-list">
		        	<div class="card-list-user">
		        	<ul>
			        	<li>
			        		<span class="class today">
			        		</span>
		        			<span  title="${topicUser.username!''}"  class="class-title">今日${todayTopics!0}</span>
			        	</li>
			        	<li>
				        	<span class="class topic"></span>
		        			<span  title="${topicUser.username!''}"  class="class-title">帖子${countTopic!0}</span>
			        	</li>
			        	<li>
				        	<span class="class user"></span>
		        			<span  title="${topicUser.username!''}"  class="class-title">会员${newUserList.totalElements!''}</span>
			        	</li>
		        	</ul>
	        		</div>
		        </div>
		    </div>
		    <div class="right-edge mobile-display-none">
		    	<a class="button-add" href="/topic/add.html">
		    	<span class="button-image-pen"></span>
		    	发布新帖</a>
	    	</div>
	    	<div class="right-edge mobile-display-none">
		        <div class="recommend-section">
		        	<span class="text">推荐板块<br><span class="text-line ">RECOMMEND</span></span>
		        </div>
		        <div class="plate-list">
			        <#if blockList??>
					<#list blockList as block>
						<#if block.type=="板块">
							<a onclick="searchHref('','${block.id!''}','${RequestParameters['q']!''}','${subtype!''}')"  class="layui-clear">
								<div class="card-list <#if block.id==cateparent>this </#if>">
				        			<span class="class"><img alt="" src="/res/blockmanagement/${block.fileurl!''}.html"></span>
				        			<span  title="${block.blockname!''}"  class="class-title">${block.blockname!''}</span>
				        		</div>
							</a>
						</#if>
					</#list>
					</#if>
		        </div>
		    </div>
		    <div class="right-edge">
		        <div class="recommend-section">
		        	<span class="text">热帖排行<br><span class="text-line mobile-display-none">RANKING</span></span>
		        </div>
		        <#if hotList?? && (hotList?size>0)>
		        <div class="post-list layui-clear">
					<ul>
						<#list hotList as relaViewsTopic>
							<li>
								<span></span>
								<a class="" href="/topic/detail/${relaViewsTopic.id!''}.html">
									${relaViewsTopic.title!''}
								</a>
							</li>
						</#list>
					</ul>
				</div>
				</#if>
		    </div>
	    </div>
	    
	  	<div style="clear: both"></div>
	  </div>
  </div>
	<div class="barrage visible-xs-block layui-hide" id="barrage">        
	    <a class="barrage_name" id="barrage_name" href="/topic/add.html">
	    </a>                   
	</div>
  <script>
  // 获取节点
  var block = document.getElementById("barrage");
  var oW,oH;     
  // 绑定touchstart事件
  block.addEventListener("touchstart", function(e) {
   
   var touches = e.touches[0];
   oW = touches.clientX - block.offsetLeft;
   oH = touches.clientY - block.offsetTop;
   //阻止页面的滑动默认事件
   console.log("touchmove");
   document.addEventListener("touchmove",defaultEvent,false);
  },false)
 
  block.addEventListener("touchmove", function(e) {
	  e.preventDefault();
   var touches = e.touches[0];
   var oLeft = touches.clientX - oW;
   var oTop = touches.clientY - oH;
   if(oLeft < 0) {
    oLeft = 0;
   }else if(oLeft > document.documentElement.clientWidth - block.offsetWidth) {
    oLeft = (document.documentElement.clientWidth - block.offsetWidth);
   }
   block.style.left = oLeft + "px";
   block.style.top = oTop + "px";
  },false);
   
  block.addEventListener("touchend",function() {
   document.removeEventListener("touchmove",defaultEvent,false);
  },false);
  function defaultEvent(e) {
   e.preventDefault();
  }
  	layui.use(['laypage', 'layer'], function(){
  		var laypage = layui.laypage;
  		/* pc端分页 */
	  	laypage({
		    cont: 'pages'
		    ,first:'首页'
		    ,last:'末页'
		    ,pages: ${defaultTopicList.totalPages}
		    ,curr:${defaultTopicList.number+1}
		    ,skin: '#32c24d'
		    ,skip: true
		    ,jump:function(obj, first){
		    	var curr = obj.curr;
		    	if(!first){
		    		searchHref("${cate!''}","${cateparent!''}","${RequestParameters['q']!''}","${subtype!'my'}",curr,'${time}')
		    	}
		    }
		});
	  	
	  	/* 移动端分页 */
	  	laypage({
		    cont: 'pagesMobile'
		    ,first:'首页'
		    ,last:'末页'
		    ,pages: ${defaultTopicList.totalPages}
		    ,curr:${defaultTopicList.number+1}
		    ,skin: '#32c24d'
		    ,jump:function(obj, first){
		    	var curr = obj.curr;
		    	if(!first){
		    		searchHref("${cate!''}","${cateparent!''}","${RequestParameters['q']!''}","${subtype!'my'}",curr,'${time}')
		    	}
		    }
		});
	});
  	
  	function showTimeLi(){
  		if($(".fly-tab a[type=hide]").css("display") == "none"){
  			$(".fly-tab a[type=hide],.fly-tab span[type=hide]").css("display","inline-block");
  			$(".list-more i").remove();
  			$(".list-more").append('<i class="layui-icon">&#xe619;</i> ');
  			$("#showList").css("height","auto");
  			
  		}else{
  			$(".fly-tab a[type=hide],.fly-tab span[type=hide]").css("display","none");
  			$(".list-more i").remove();
  			$(".list-more").append('<i class="layui-icon">&#xe61a;</i> ');
  			$("#showList").css("height","30px");
  		}
  	}
  	
  	function showBriefintroduction(){
  		if($(".briefintroduction-substring").hasClass("layui-hide")){
  			$(".briefintroduction-substring").removeClass("layui-hide");
  			$(".briefintroduction-allsubstring").addClass("layui-hide");
  		}else{
  			$(".briefintroduction-allsubstring").removeClass("layui-hide");
  			$(".briefintroduction-substring").addClass("layui-hide");
  		}
  		
  	}
  	
  	function fans(id){
  		$.ajax({
  	        type: "POST",
  	        url: "/user/fans/"+id,
  	        data: {},
  	        success: function(data){
  	        	if(data == "success"){
  	        		$("#followsB"+id+" b").text("已关注");
  	        		$("#followsB"+id).attr("onclick","unfans('"+id+"')");
  	        		layer.msg('关注成功', {icon: 1});
  	        	}else{
  	        		layer.msg('关注失败', {icon: 2});
  	        	}
  	        }
  	    });
  	}
  	function unfans(id){
  		$.ajax({
  	        type: "POST",
  	        url: "/user/unfans/"+id,
  	        data: {},
  	        success: function(data){
  	        	if(data == "success"){
  	        		$("#followsB"+id+" b").text("关注");
  	        		$("#followsB"+id).attr("onclick","fans('"+id+"')");
  	        		layer.msg('取消关注成功', {icon: 1});
  	        	}else{
  	        		layer.msg('取消关注失败', {icon: 2});
  	        	}
  	        }
  	    });
  	}
  </script>